package cn.edu.scau.cmi.suyaoxing.client;

import cn.edu.scau.cmi.suyaoxing.singleton.Marshel;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;


public class MultitonClient extends Application{
   public static void main(String[] args) {
       launch(args);
    }
   @Override
   public void start(Stage primaryStage) {
	   GridPane gridpane=new GridPane();
       gridpane.setAlignment(Pos.CENTER);
	   
       TextArea ta=new TextArea();
       ta.setPrefWidth(700);
       Button btn = new Button();
       btn.setText("获取元帅");
       btn.setOnAction(new EventHandler<ActionEvent>() {
           @Override
           public void handle(ActionEvent event) {
        	   ta.appendText(Marshel.getRandomInstance()+"\n");
           }
       });
       gridpane.add(btn, 0, 0);
       gridpane.add(ta, 0, 1);
       
       Scene scene=new Scene(gridpane,1000,500);
       primaryStage.setTitle("实验二多例模式");
       primaryStage.setScene(scene);
       primaryStage.show();
    }
}